Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error logs to the training loop #140

Closed
wants to merge 7 commits into from

Conversation

sweep-nightly[bot]
Copy link

@sweep-nightly sweep-nightly bot commented Oct 28, 2023

Description

This PR adds error logging functionality to the training loop in src/main.py. It uses Python's built-in logging module to log any exceptions that occur during training to a file named training.log.

Summary of Changes

  • Added import logging statement at the top of src/main.py
  • Added logging.basicConfig(filename='training.log', level=logging.ERROR) to configure the logging module
  • Added error logging to the training loop using a try/except block and logging.exception("Error occurred during training") statement

Fixes #1.


🎉 Latest improvements to Sweep:

  • Sweep can now passively improve your repository! Check out Rules to learn more.

💡 To get Sweep to edit this pull request, you can:

  • Comment below, and Sweep can edit the entire PR
  • Comment on a file, Sweep will only modify the commented file
  • Edit the original issue to get Sweep to recreate the PR from scratch

@sweep-nightly
Copy link
Author

sweep-nightly bot commented Oct 28, 2023

Sandbox Executions

  • Check src/main.py
Sandbox logs for
trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...


  FAILURES  
 black  src/main.py  .trunk/out/y1xWK.yaml
 black  src/main.py  .trunk/out/s2qNv.yaml
  NOTICES  
 Some tools failed to run. You can open the details yaml files for more information.
Checked 1 file
✖ No issues, 2 failures
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ❌ (`1`)
  ISSUES  
src/main.py:13:3
 13:3  high  SyntaxError: Unexpected token 'from'  ruff/E999
  FAILURES  
 black  src/main.py  .trunk/out/y0NlU.yaml
  NOTICES  
 A tool failed to run. You can open the details yaml file for more information.
Checked 1 file
✖ 1 new issue
# .trunk/out/y0NlU.yaml
trunk_cli_version: 1.17.1
title: black exited with exit_code=123
report:
  - black exited with exit_code=123
  - linter:
      command: |
        /root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin/black -q src/main.py
      stdin_path: (none)
      run_from: /tmp/trunk-0/ByQlWN
      timeout: 10m
      rerun: (cd /tmp/trunk-0/ByQlWN; env -i PATH=/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin:/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/Scripts:/root/.cache/trunk/tools/python/3.10.8-b6e96641f2c120698c300f1bdd98bc0e/bin:/root/.cache/trunk/tools/python/3.10.8-b6e96641f2c120698c300f1bdd98bc0e HOME=/root PYTHONUTF8=1 VIRTUAL_ENV=/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d /root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin/black -q src/main.py)
      affects_cache:
        []
      direct_configs:
        []
      exit_status: exited
      exit_code: 123
      stdout: (none)
      stderr: |
        error: cannot format src/main.py: Cannot parse: 13:2: ])from PIL import Image
    parser: |
      (none)
  • Check src/main.py
Sandbox logs for
trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...


Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ❌ (`1`)
 ✔ Auto-fixed src/main.py
Re-checking autofixed files...


  ISSUES  
src/main.py:2:13
  2:13  high  Undefined name `transforms`                              ruff/F821
  3:6   high  Undefined name `transforms`                              ruff/F821
  3:29  high  Undefined name `transforms`                              ruff/F821
  7:13  high  Undefined name `transforms`                              ruff/F821
  8:6   high  Undefined name `transforms`                              ruff/F821
  8:29  high  Undefined name `transforms`                              ruff/F821
 10:1   high  Module level import not at top of file                   ruff/E402
 14:12  high  Undefined name `datasets`                                ruff/F821
 15:15  high  Undefined name `DataLoader`                              ruff/F821
 19:11  high  Undefined name `nn`                                      ruff/F821
 22:20  high  Undefined name `nn`                                      ruff/F821
 23:20  high  Undefined name `nn`                                      ruff/F821
 24:20  high  Undefined name `nn`                                      ruff/F821
 28:13  high  Undefined name `nn`                                      ruff/F821
 29:13  high  Undefined name `nn`                                      ruff/F821
 31:16  high  Undefined name `nn`                                      ruff/F821
 36:13  high  Undefined name `optim`                                   ruff/F821
 37:13  high  Undefined name `nn`                                      ruff/F821
 41:5   high  Loop control variable `epoch` not used within loop body  ruff/B007
 52:1   high  Undefined name `torch`                                   ruff/F821
Checked 1 file
1 existing issue (1 auto-fixable)
✖ 19 new issues
  • Check src/main.py
Sandbox logs for
trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...

 ✔ Formatted src/main.py
Re-checking autofixed files...


Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ❌ (`1`)
 ✔ Auto-fixed src/main.py
Re-checking autofixed files...


  ISSUES  
src/main.py:16:1
 16:1  high  Module level import not at top of file                   ruff/E402
 47:5  high  Loop control variable `epoch` not used within loop body  ruff/B007
Checked 1 file
1 existing issue (1 auto-fixable)
✖ 1 new issue
  • Check src/main.py
Sandbox logs for
trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...

 ✔ Formatted src/main.py
Re-checking autofixed files...


Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ❌ (`1`)
 ✔ Auto-fixed src/main.py
Re-checking autofixed files...


  ISSUES  
src/main.py:13:1
 13:1  high  Module level import not at top of file        ruff/E402
 13:8  high  Redefinition of unused `logging` from line 1  ruff/F811
Checked 1 file
✖ 2 new issues
  • Check src/main.py
Sandbox logs for
trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...

 ✔ Formatted src/main.py
Re-checking autofixed files...


Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ❌ (`1`)
 ✔ Auto-fixed src/main.py
Re-checking autofixed files...


  ISSUES  
src/main.py:13:1
 13:1  high  Module level import not at top of file  ruff/E402
Checked 1 file
✖ 1 new issue
  • Check src/main.py
Sandbox logs for https://github.com/sweepai/evals/commit/e71107662deecbe084fc7629526bfd5952ebf7cb
trunk fmt src/main.py || exit 0 1/4 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...

 ✔ Formatted src/main.py
Re-checking autofixed files...


Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/4 ✓
 ✔ Auto-fixed src/main.py
Re-checking autofixed files...


Checked 1 file
✔ No issues
if [[ $(echo "src/main.py" | grep 'test.*\.py$') ]]; then PYTHONPATH=. python src/main.py; else exit 0; fi 3/4 ✓
(nothing was outputted)
if [[ "src/main.py" == *test*.py ]]; then PYTHONPATH=. pytest src/main.py; else exit 0; fi 4/4 ✓
(nothing was outputted)
  • Check src/main.py
Sandbox logs for
trunk fmt src/main.py || exit 0 1/4 ✓
Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/4 ✓
Checked 1 file
✔ No issues
if [[ $(echo "src/main.py" | grep 'test.*\.py$') ]]; then PYTHONPATH=. python src/main.py; else exit 0; fi 3/4 ✓
(nothing was outputted)
if [[ "src/main.py" == *test*.py ]]; then PYTHONPATH=. pytest src/main.py; else exit 0; fi 4/4 ✓
(nothing was outputted)
  • Check src/main.py
Sandbox logs for
trunk fmt src/main.py || exit 0 1/4 ✓
Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/4 ✓
Checked 1 file
✔ No issues
if [[ $(echo "src/main.py" | grep 'test.*\.py$') ]]; then PYTHONPATH=. python src/main.py; else exit 0; fi 3/4 ✓
(nothing was outputted)
if [[ "src/main.py" == *test*.py ]]; then PYTHONPATH=. pytest src/main.py; else exit 0; fi 4/4 ✓
(nothing was outputted)
  • Check src/main.py
Sandbox logs for
pip install -r requirements.txt 1/1 ❌ (`1`)
Looking in links: https://download.pytorch.org/whl/torch_stable.html
DEPRECATION: The HTML index page being used (https://download.pytorch.org/whl/torch_stable.html) is not a proper HTML 5 document. This is in violation of PEP 503 which requires these pages to be well-formed HTML 5 documents. Please reach out to the owners of this index page, and ask them to update this index page to a valid HTML 5 document. pip 22.2 will enforce this behaviour change. Discussion can be found at https://github.com/pypa/pip/issues/10825
Collecting annotated-types==0.6.0
  Downloading annotated_types-0.6.0-py3-none-any.whl (12 kB)
Collecting anyio==3.7.1
  Downloading anyio-3.7.1-py3-none-any.whl (80 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 80.9/80.9 KB 766.9 kB/s eta 0:00:00
Collecting astroid==3.0.1
  Downloading astroid-3.0.1-py3-none-any.whl (275 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 275.2/275.2 KB 3.4 MB/s eta 0:00:00
Collecting certifi==2022.12.7
  Downloading certifi-2022.12.7-py3-none-any.whl (155 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.3/155.3 KB 4.4 MB/s eta 0:00:00
Collecting charset-normalizer==2.1.1
  Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Requirement already satisfied: click==8.1.7 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 7)) (8.1.7)
Collecting dill==0.3.
  Downloading dill-0.3.0.tar.gz (151 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 151.4/151.4 KB 3.6 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
ERROR: Could not find a version that satisfies the requirement distutils (from versions: none)
ERROR: No matching distribution found for distutils
  • Check requirements.txt
Run requirements.txt through the sandbox.
  • Check src/main.py
Sandbox logs for
pip install -r requirements.txt 1/1 ❌ (`1`)
Looking in links: https://download.pytorch.org/whl/torch_stable.html
DEPRECATION: The HTML index page being used (https://download.pytorch.org/whl/torch_stable.html) is not a proper HTML 5 document. This is in violation of PEP 503 which requires these pages to be well-formed HTML 5 documents. Please reach out to the owners of this index page, and ask them to update this index page to a valid HTML 5 document. pip 22.2 will enforce this behaviour change. Discussion can be found at https://github.com/pypa/pip/issues/10825
Collecting annotated-types==0.6.0
  Downloading annotated_types-0.6.0-py3-none-any.whl (12 kB)
Collecting anyio==3.7.1
  Downloading anyio-3.7.1-py3-none-any.whl (80 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 80.9/80.9 KB 766.9 kB/s eta 0:00:00
Collecting astroid==3.0.1
  Downloading astroid-3.0.1-py3-none-any.whl (275 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 275.2/275.2 KB 3.4 MB/s eta 0:00:00
Collecting certifi==2022.12.7
  Downloading certifi-2022.12.7-py3-none-any.whl (155 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.3/155.3 KB 4.4 MB/s eta 0:00:00
Collecting charset-normalizer==2.1.1
  Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Requirement already satisfied: click==8.1.7 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 7)) (8.1.7)
Collecting dill==0.3.
  Downloading dill-0.3.0.tar.gz (151 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 151.4/151.4 KB 3.6 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
ERROR: Could not find a version that satisfies the requirement distutils (from versions: none)
ERROR: No matching distribution found for distutils
  • Check src/main.py
Sandbox logs for
trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...


Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ❌ (`1`)
 ✔ Auto-fixed src/main.py
Re-checking autofixed files...


  ISSUES  
src/main.py:2:13
  2:13  high  Undefined name `transforms`                              ruff/F821
  3:6   high  Undefined name `transforms`                              ruff/F821
  3:29  high  Undefined name `transforms`                              ruff/F821
  7:13  high  Undefined name `transforms`                              ruff/F821
  8:6   high  Undefined name `transforms`                              ruff/F821
  8:29  high  Undefined name `transforms`                              ruff/F821
 10:1   high  Module level import not at top of file                   ruff/E402
 14:12  high  Undefined name `datasets`                                ruff/F821
 15:15  high  Undefined name `DataLoader`                              ruff/F821
 19:11  high  Undefined name `nn`                                      ruff/F821
 22:20  high  Undefined name `nn`                                      ruff/F821
 23:20  high  Undefined name `nn`                                      ruff/F821
 24:20  high  Undefined name `nn`                                      ruff/F821
 28:13  high  Undefined name `nn`                                      ruff/F821
 29:13  high  Undefined name `nn`                                      ruff/F821
 31:16  high  Undefined name `nn`                                      ruff/F821
 36:13  high  Undefined name `optim`                                   ruff/F821
 37:13  high  Undefined name `nn`                                      ruff/F821
 41:5   high  Loop control variable `epoch` not used within loop body  ruff/B007
 52:1   high  Undefined name `torch`                                   ruff/F821
Checked 1 file
1 existing issue (1 auto-fixable)
✖ 19 new issues
  • Check src/main.py
Sandbox logs for
trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...


  FAILURES  
 black  src/main.py  .trunk/out/y1xWK.yaml
 black  src/main.py  .trunk/out/s2qNv.yaml
  NOTICES  
 Some tools failed to run. You can open the details yaml files for more information.
Checked 1 file
✖ No issues, 2 failures
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ❌ (`1`)
  ISSUES  
src/main.py:13:3
 13:3  high  SyntaxError: Unexpected token 'from'  ruff/E999
  FAILURES  
 black  src/main.py  .trunk/out/y0NlU.yaml
  NOTICES  
 A tool failed to run. You can open the details yaml file for more information.
Checked 1 file
✖ 1 new issue
# .trunk/out/y0NlU.yaml
trunk_cli_version: 1.17.1
title: black exited with exit_code=123
report:
  - black exited with exit_code=123
  - linter:
      command: |
        /root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin/black -q src/main.py
      stdin_path: (none)
      run_from: /tmp/trunk-0/ByQlWN
      timeout: 10m
      rerun: (cd /tmp/trunk-0/ByQlWN; env -i PATH=/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin:/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/Scripts:/root/.cache/trunk/tools/python/3.10.8-b6e96641f2c120698c300f1bdd98bc0e/bin:/root/.cache/trunk/tools/python/3.10.8-b6e96641f2c120698c300f1bdd98bc0e HOME=/root PYTHONUTF8=1 VIRTUAL_ENV=/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d /root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin/black -q src/main.py)
      affects_cache:
        []
      direct_configs:
        []
      exit_status: exited
      exit_code: 123
      stdout: (none)
      stderr: |
        error: cannot format src/main.py: Cannot parse: 13:2: ])from PIL import Image
    parser: |
      (none)

@sweep-nightly
Copy link
Author

sweep-nightly bot commented Oct 28, 2023

Apply Sweep Rules to your PR?

  • Apply: All docstrings and comments should be up to date.
  • Apply: Code should be properly formatted and indented.
  • Apply: Variable and function names should be descriptive and follow a consistent naming convention.
  • Apply: Imports should be organized and grouped together.
  • Apply: There should be no unused imports or variables.
  • Apply: Code should be properly commented and include docstrings for functions and classes.

@sweep-nightly sweep-nightly bot added the sweep label Oct 28, 2023
@sweep-nightly sweep-nightly bot closed this Oct 29, 2023
@sweep-nightly sweep-nightly bot deleted the sweep/add-error-logs_11 branch October 29, 2023 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sweep: add error logs to the training loop
0 participants